org.eclipse.vtp.framework.common.services
Class VariableRegistry

java.lang.Object
  extended by org.eclipse.vtp.framework.common.services.VariableRegistry
All Implemented Interfaces:
IScriptable, IVariableRegistry

public class VariableRegistry
extends java.lang.Object
implements IVariableRegistry, IScriptable

A support implementation of the IVariableRegistry interface.

Author:
Lonnie Pryor

Constructor Summary
VariableRegistry(ISessionContext context, IDataTypeRegistry dataTypeRegistry)
          Creates a new VariableRegistry.
 
Method Summary
 boolean clearEntry(java.lang.String name)
           
 boolean clearItem(int index)
           
 void clearVariable(java.lang.String name)
          Removes the registration of the variable under the specified name
 IDataObject createVariable(IDataType type)
          Creates a new variable of the specified type.
 IDataObject createVariable(java.lang.String typeName)
          Creates a new variable of the specified type.
 java.lang.Object getEntry(java.lang.String name)
           
 java.lang.String[] getFunctionNames()
           
 java.lang.Object getItem(int index)
           
 java.lang.String getName()
           
 IDataObject getVariable(java.lang.String name)
          Returns the variable registered under the specified name or null if no such variable is registered.
 java.lang.String[] getVariableNames()
          Returns the names of all the variables currently registered.
 boolean hasEntry(java.lang.String name)
           
 boolean hasItem(int index)
           
 boolean hasValue()
           
 java.lang.Object invokeFunction(java.lang.String name, java.lang.Object[] arguments)
           
 boolean setEntry(java.lang.String name, java.lang.Object value)
           
 boolean setItem(int index, java.lang.Object value)
           
 void setVariable(java.lang.String name, IDataObject variable)
          Registers a variable under the specified name, removing any variable previously registered under that name.
 java.lang.Object toValue()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableRegistry

public VariableRegistry(ISessionContext context,
                        IDataTypeRegistry dataTypeRegistry)
Creates a new VariableRegistry.

Parameters:
context - The context to use.
dataTypeRegistry - The data type registry to use.
Method Detail

createVariable

public final IDataObject createVariable(java.lang.String typeName)
                                 throws java.lang.IllegalArgumentException,
                                        java.lang.NullPointerException
Description copied from interface: IVariableRegistry
Creates a new variable of the specified type.

Specified by:
createVariable in interface IVariableRegistry
Parameters:
typeName - The name of the type of variable to create.
Returns:
A new variable of the specified type.
Throws:
java.lang.IllegalArgumentException - If no type with the specified name exists.
java.lang.NullPointerException - If the supplied type name is null.

createVariable

public final IDataObject createVariable(IDataType type)
                                 throws java.lang.IllegalArgumentException,
                                        java.lang.NullPointerException
Description copied from interface: IVariableRegistry
Creates a new variable of the specified type.

Specified by:
createVariable in interface IVariableRegistry
Parameters:
type - The type of variable to create.
Returns:
A new variable of the specified type.
Throws:
java.lang.NullPointerException - If the supplied type is null.
java.lang.IllegalArgumentException

getVariableNames

public final java.lang.String[] getVariableNames()
Description copied from interface: IVariableRegistry
Returns the names of all the variables currently registered.

Specified by:
getVariableNames in interface IVariableRegistry
Returns:
The names of all the variables currently registered.

getVariable

public final IDataObject getVariable(java.lang.String name)
                              throws java.lang.NullPointerException
Description copied from interface: IVariableRegistry
Returns the variable registered under the specified name or null if no such variable is registered.

Specified by:
getVariable in interface IVariableRegistry
Parameters:
name - The name of the variable to return.
Returns:
The variable registered under the specified name or null if no such variable is registered.
Throws:
java.lang.NullPointerException - If the supplied variable name is null.

setVariable

public final void setVariable(java.lang.String name,
                              IDataObject variable)
                       throws java.lang.IllegalArgumentException,
                              java.lang.NullPointerException
Description copied from interface: IVariableRegistry
Registers a variable under the specified name, removing any variable previously registered under that name.

Specified by:
setVariable in interface IVariableRegistry
Parameters:
name - The name to register the variable under.
Throws:
java.lang.IllegalArgumentException - If the supplied variable was not created by this registry.
java.lang.NullPointerException - If the supplied variable name is null.

clearVariable

public final void clearVariable(java.lang.String name)
                         throws java.lang.NullPointerException
Description copied from interface: IVariableRegistry
Removes the registration of the variable under the specified name

Specified by:
clearVariable in interface IVariableRegistry
Parameters:
name - The name of the variable to clear.
Throws:
java.lang.NullPointerException - If the supplied variable name is null.

getName

public final java.lang.String getName()
Specified by:
getName in interface IScriptable

hasValue

public boolean hasValue()
Specified by:
hasValue in interface IScriptable

toValue

public java.lang.Object toValue()
Specified by:
toValue in interface IScriptable

getFunctionNames

public final java.lang.String[] getFunctionNames()
Specified by:
getFunctionNames in interface IScriptable

invokeFunction

public final java.lang.Object invokeFunction(java.lang.String name,
                                             java.lang.Object[] arguments)
Specified by:
invokeFunction in interface IScriptable

hasItem

public final boolean hasItem(int index)
Specified by:
hasItem in interface IScriptable

hasEntry

public final boolean hasEntry(java.lang.String name)
Specified by:
hasEntry in interface IScriptable

getItem

public final java.lang.Object getItem(int index)
Specified by:
getItem in interface IScriptable

getEntry

public final java.lang.Object getEntry(java.lang.String name)
Specified by:
getEntry in interface IScriptable

setItem

public final boolean setItem(int index,
                             java.lang.Object value)
Specified by:
setItem in interface IScriptable

setEntry

public final boolean setEntry(java.lang.String name,
                              java.lang.Object value)
Specified by:
setEntry in interface IScriptable

clearItem

public final boolean clearItem(int index)
Specified by:
clearItem in interface IScriptable

clearEntry

public final boolean clearEntry(java.lang.String name)
Specified by:
clearEntry in interface IScriptable